
local art = class.panel.create('',10,50,86,64,24,4)

local ui = art:add_text('',0,0,nil,nil,24,5)
ui:set_color(0xffff0000)

function ui:update()
    if self.timer then
        local num = self.timer:get_remaining()/1000
        if num>1 then
            self:set_text(('%0.f'):format(num))
        else
            self:set_text(('%0.1f'):format(num))
        end
        self:show()
        if num<=0 then
            self.timer = nil
        end
    else
        self:hide()
    end
end

ac.hardware:event '界面绘制'(function()
    ui:update()
end)


ac.game:event '单位-显示复活时间'(function(_,hero,timer)
    local player = hero.owner
    if player:is_self() then
        ui.timer = timer
    end
end)